from django.db import models
from users.models import BaseModel

# Create your models here.


# 菜单表
class MenuModel(BaseModel):
    name = models.CharField(verbose_name="菜单名称", max_length=30)
    url = models.CharField(verbose_name="路由", max_length=50, default="")
    class Meta:
        db_table = "menu_tb"
        verbose_name = "菜单表"
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.name


# 菜单标签子类
class MenuSubClassModel(BaseModel):
    menu_name = models.CharField(max_length=30, verbose_name="菜单子类名字")
    url = models.CharField(max_length=50, verbose_name="菜单路由", default="")
    menu_id = models.BigIntegerField(verbose_name="所属菜单id")

    class Meta:
        db_table = "menu_sub_class_tb"
        verbose_name = "菜单子类表"
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.menu_name


# 菜单角色中间表
class MenuRoleModel(BaseModel):
    role_id = models.BigIntegerField(verbose_name="所属角色id")
    menu_id = models.BigIntegerField(verbose_name="所属菜单id")

    class Meta:
        db_table = "menu_role_tb"
        verbose_name = "菜单角色表"
        verbose_name_plural = verbose_name
    def __str__(self):
        return f"菜单{self.menu_id}, 角色{self.role_id}"


# 轮播图表
class SlideshowModel(BaseModel):
    image = models.CharField(max_length=256, verbose_name='轮播图')
    desc = models.CharField(max_length=60, verbose_name="简介", null=True, blank=True)

    class Meta:
        db_table = 'slideshow_tb'
        verbose_name = "轮播图表"
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.image